//
//  HTOtherInfoViewController.m
//  HTDemo
//
//  Created by meet on 14-3-14.
//  Copyright (c) 2014年 HT. All rights reserved.
//

#import "HTOtherInfoViewController.h"

static NSString * const kUrlBlog  = @"http://blog.csdn.net/whoten";
static NSString * const kUrlWeibo = @"http://weibo.com/u/1582183477";
static NSString * const kUrlPhone = @"tel://18215606266";
static NSString * const kUrlEmail = @"mailto://uestc.ht@gmail.com";

typedef enum HTOtherInfoType{
    HTOtherInfoTypeBlog = 100,
    HTOtherInfoTypeWeibo,
    HTOtherInfoTypePhone,
    HTOtherInfoTypeEmail
}HTOtherInfoType;

@interface HTOtherInfoViewController ()

@end

@implementation HTOtherInfoViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationItem.title = @"相关信息";
    self.view.backgroundColor = [UIColor whiteColor];
    [self drawTurnButton];
}

- (void)drawTurnButton
{
    CGFloat fontSize = 30;
    NSArray *titles = @[@"跳转到博客",@"跳转到微博",@"给胡腾打电话面试",@"给胡腾发送邮件"];
    NSArray *tags = @[[NSNumber numberWithInteger:HTOtherInfoTypeBlog],
                      [NSNumber numberWithInteger:HTOtherInfoTypeWeibo],
                      [NSNumber numberWithInteger:HTOtherInfoTypePhone],
                      [NSNumber numberWithInteger:HTOtherInfoTypeEmail]];
    
    for (int i = 0 ; i != titles.count; i++) {
        UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeCustom];
        infoButton.frame = CGRectMake(0, Screen_Height*(i+1)/5, Screen_Width , fontSize);
        [infoButton setTitle:titles[i] forState:UIControlStateNormal];
        [infoButton setTitleColor:COLOR_INFO forState:UIControlStateNormal];
        infoButton.titleLabel.font = [UIFont systemFontOfSize:fontSize];
        infoButton.tag = [tags[i] integerValue];
        [infoButton addTarget:self action:@selector(infoButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:infoButton];
    }
}

- (void)infoButtonPressed:(id)sender
{
    UIButton *info = (UIButton *)sender;
    NSString *urlStr;
    switch (info.tag) {
        case HTOtherInfoTypeBlog:{
            
            urlStr = kUrlBlog;
        }
            break;
        case HTOtherInfoTypeWeibo:{
            
            urlStr = kUrlWeibo;
        }
            break;
        case HTOtherInfoTypePhone:{
            
            urlStr = kUrlPhone;
        }
        default:{
            
            urlStr = kUrlEmail;
        }
            break;
    }
    
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
}

@end
